<?php
    session_start();
    require "./functions.php";
    $nickname = $_POST['nickname'];
//    $sex = $_POST['sex'];
    $QQ = $_POST['QQ'];
    $email = $_POST['email'];
    $file = $_FILES['file'];

    $path="../../public/home/img/";
    $maxsize=0;
    $fileType=array("image/jpeg","image/gif","image/png");
    $res=upload($path,$fileType,$maxSize=0,$file);
    //             var_dump($res);
    $newName = $res['newName'];

    $line = "x_";
    $maxw =50;
    $maxh =50;
    getImages($path,$newName,$line,$maxw,$maxh);

    //    $path = rtrim($path,'/').'/';
    $newfile = $line.$newName;

    $link = mysqli_connect("localhost","root","") or die("数据连接失败");
    mysqli_set_charset($link,"utf8");
    mysqli_select_db($link,"bbs");
    $sql = "update userdetail set nickName='{$nickname}',qq='{$QQ}',photo='{$newfile}',email='{$email}' where uid={$_SESSION['id']}";
    mysqli_query($link,$sql);
    if(mysqli_affected_rows($link)>0){
        echo "<script>alert('修改成功！');window.location.href='../userdetailedit.php';</script>";
        die;
    }else{
        echo "<script>alert('修改失败！');window.location.href='../userdetailedit.php';</script>";
        die;
    }
    mysqli_close($link);